package com.hmkj.core.mapper.investor;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.model.investor.InvestorSimulateModel;
import com.hmkj.core.po.investor.InvestorSimulate;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 模拟投资人表相关Dao接口<br>
 *
 * @author eproo
 * @date   2017-11-09 05:38:59
 */
public interface InvestorSimulateMapper extends GenericMapper< InvestorSimulate,Integer> {

    @Select("SELECT t.*,u.id AS 'u.id', u.user_name AS 'u.userName',u.mobile AS 'u.mobile'FROM biz_investor_simulate t LEFT JOIN biz_user u ON t.user_id = u.id WHERE 1 = 1 ${whereSql} ${sortSql} LIMIT ${nowPage}, ${pageSize}")
    List<InvestorSimulateModel> findListBySqlJoin(Map<String, Object> params);

    @Select("SELECT count(1)  FROM biz_investor_simulate t LEFT JOIN biz_user u ON t.user_id = u.id WHERE 1=1 ${whereSql}")
    long countBySqlJoin(Map<String, Object> params);

    /**
     * 查询符合条件的投资人账户
     * @param agentId 代理商Id
     * @return
     */
    @Select("SELECT i.* FROM biz_investor_simulate i LEFT JOIN biz_user u ON i.user_id = u.id WHERE ISNULL(i.id)!=1 AND i.status = 1 AND u.agent_id = #{agentId} ")
    List<InvestorSimulate> selectByAgent(@Param(value = "agentId") Integer agentId);
}
